package ltd.smallwang.web.convert;

import ltd.smallwang.client.task.dto.TaskDto;
import ltd.smallwang.domain.task.Task;
import ltd.smallwang.domain.task.constant.CompleteFlagEnum;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;

/**
 * @author justd
 * @description 功能描述
 * @since 2024-04-21 20:38
 **/
@Mapper
public interface TaskConvert {

  TaskConvert INSTANCE = Mappers.getMapper(TaskConvert.class);

  @Mapping(source = "completeFlagEnum", target = "completeFlag", qualifiedByName = "completeFlagEnumToInteger")
  TaskDto convert(Task task);

  @Named("completeFlagEnumToInteger")
  default Integer completeFlagEnumToBoolean(CompleteFlagEnum completeFlagEnum) {
    return completeFlagEnum.getCompleteFlag();
  }
}
